

int minimumRecolors(char *blocks, int k)
{
    int length = strlen(blocks);
    int minedit = k;
    for (int i = 0; i < length - k + 1; i++)
    {
        int B = 0;
        int edit = 0;
        for (int j = i; j < i + k; j++)
        {
            if (B < k)
            {
                if (blocks[j] != 'B')
                {
                    edit++;
                    B++;
                }
                else
                    B++;
            }
        }
        if (minedit > edit)
        {
            minedit = edit;
        }
    }
    return minedit;
}